package com.cx.service.czw.impl;

import com.cx.mapper.UserMapper;
import com.cx.pojo.User;
import com.cx.pojo.UserExample;
import com.cx.service.czw.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegisterImpl implements RegisterService {
    @Autowired
    UserMapper userMapper;


    @Override
    public int userRegister(String phone, String pwd) {
        User user = new User();
        user.setUserPhone(phone);
        user.setUserPassword(pwd);
        int AffectRows = userMapper.insertSelective(user);
        return AffectRows;
    }


    @Override
    public User userCheckPhone(String phone) {
        UserExample userExample =new UserExample();
        userExample.createCriteria().andUserPhoneEqualTo(phone);
        List<User> userList = userMapper.selectByExample(userExample);
        if(null != userList && userList.size()>0){
            return userList.get(0);
        }else {
            return null;
        }
    }
}
